package javasec.seed;

import java.lang.reflect.Method;
import java.io.Serializable;

public class SeedMethod implements Serializable
{
	private static final long serialVersionUID = -8407585188841136345L;

	private String methodName;
	private String methodDescription; //
	private Class[] parameterTypes;  
	private String[] parameterNames; //
	private Class returnType;

	public SeedMethod(Method method)
	{
		// make sure the method is annotated
		if(!method.isAnnotationPresent(Exposed.class))
		{
			System.out.println("warning: method is not annotated");
		}

		// assign all the fields
		methodName=method.getName();
		methodDescription=method.getAnnotation(Exposed.class).description();
		parameterTypes=method.getParameterTypes();
		parameterNames=method.getAnnotation(Exposed.class).arguments();
		returnType=method.getReturnType();

		// make sure everything is good
		if(parameterTypes.length!=parameterNames.length)
		{
			System.out.println("warning: there are "+parameterTypes.length+" parameter types and "+parameterNames.length+"names in this method");
		}
	}

	public String getName()
	{
		return methodName;
	}

	public String getMethodDescription()
	{
		return methodDescription;
	}

	public Class[] getParameterTypes()
	{
		return parameterTypes;
	}

	public String[] getParameterNames()
	{
		return parameterNames;
	}

	public Class getReturnType()
	{
		return returnType;
	}
}
